﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NineApiTest
{
    public class Data
    {
       public static List<Order>_OrderCache = new List<Order>();
        public static void LoadData()
        {
            string jsonStr = File.ReadAllText("Data.json");
            if (!string.IsNullOrEmpty(jsonStr))
            {
                _OrderCache=JsonConvert.DeserializeObject<List<Order>>(jsonStr);
            }
        }

        public static void SaveData()
        {
            string jsonStr = JsonConvert.SerializeObject(_OrderCache);
            File.WriteAllText("Data.json", jsonStr);
        }

        public static int GetNewId()
        {
            return _OrderCache.Count+1;
        }

        public static void CheckStatus(string payNo)
        {

        }
    }

    public class Order
    {
        public int ID { get; set; } 

        public string Name { get; set; }
       
        public string OrderNo { get; set; }
        public string PayNo { get; set; }

        public int Status { get; set; }
    }
}
